import React from 'react'
import ReactDOM from 'react-dom/client'
import './index.css'
import App from './App'
// import reportWebVitals from './reportWebVitals
let root = ReactDOM.createRoot(document.getElementById('root'))

function render(props) {
  if (!root._internalRoot) {
    root = ReactDOM.createRoot(document.getElementById('root'))
  }

  root.render(
    <React.StrictMode>
      <App />
    </React.StrictMode>
  )
}
// reportWebVitals();

if (window.__POWERED_BY_QIANKUN__) {
  // eslint-disable-next-line
  __webpack_public_path__ = window.__INJECTED_PUBLIC_PATH_BY_QIANKUN__
}

if (!window.__POWERED_BY_QIANKUN__) {
  // 独立运行微应用
  render()
}

export async function bootstrap(props) {}

export async function mount(props) {
  render(props)
}

export async function unmount(props) {
  root.unmount()
}

export async function update(props) {
  console.log('update props', props);
}
